package com.ropeok.service.impl;

import com.ropeok.dao.RolePrivilegeDao;
import com.ropeok.entity.RolePrivilege;
import com.ropeok.service.PrivilegeService;
import com.ropeok.service.RolePrivilegeService;
import org.mybatis.logging.Logger;
import org.mybatis.logging.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @BelongsProject: task2
 * @BelongsPackage: com.ropeok.service
 * @Author: zhofeifan
 * @CreateTime: 2022-08-23  14:50
 * @Description: TODO
 * @Version: 1.0
 */
@Service("rolePrivilegeService")
public class RolePrivilegeImpl  implements RolePrivilegeService {
    private static Logger logger= LoggerFactory.getLogger(RolePrivilegeService.class);
    @Autowired
    private RolePrivilegeDao rolePrivilegeDao;
    /**
     * @description: 根据ID查询用户权限表
     * @author: zhoufeifan
     * @date: 2022/9/15 10:26
     * @param: [long]
     * @return: com.ropeok.entity.RolePrivilege
    **/

    @Override
    public RolePrivilege findRolePrivilegeById(long id) {
        return rolePrivilegeDao.findRolePrivilegeById(id);
    }
    /**
     * @description: 查询用户权限列表
     * @author: zhoufeifan
     * @date: 2022/9/15 10:26
     * @param: []
     * @return: java.util.List<com.ropeok.entity.RolePrivilege>
    **/

    @Override
    public List<RolePrivilege> getRolePrivilegeList() {
        List<RolePrivilege> rolePrivilegeList = rolePrivilegeDao.getRolePrivilegeList();
        return  rolePrivilegeList;
    }
    /**
     * @description: 增加用户权限记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:27
     * @param: [com.ropeok.entity.RolePrivilege]
     * @return: int
    **/
    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int addRolePrivilege(RolePrivilege rolePrivilege) {
        return rolePrivilegeDao.addRolePrivilege(rolePrivilege);
    }
    /**
     * @description: 删除用户权限记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:27
     * @param: [long]
     * @return: int
    **/
    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int deleteRolePrivilege(long id) {
        return rolePrivilegeDao.deleteRolePrivilege(id);
    }
    /**
     * @description:  更新用户权限记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:28
     * @param: [com.ropeok.entity.RolePrivilege]
     * @return: int
    **/

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int updateRolePrivilege(RolePrivilege rolePrivilege) {
        return rolePrivilegeDao.updateRolePrivilege(rolePrivilege);
    }
}
